#ifndef _LOOP_H
#define _LOOP_H

#include <QMutex>
#include <string.h> //memset
#include <list>
typedef int (*loop_search_func)(const void *, const void *);

struct qqpacket;

struct loop{
	QMutex	mutex;	
	std::list<qqpacket*>	items;
};

void moveToHead(loop* l,loop* r,bool lockLeftFirst);
qqpacket* loop_pop_from_tail( loop* l );
qqpacket* loop_pop_from_head( loop* l );
int loop_push_to_head( loop* l, qqpacket* data );
int loop_push_to_tail( loop* l, qqpacket* data );
qqpacket* loop_search( loop* l, void*, loop_search_func search );
qqpacket* loop_search_without_lock( loop* l, void* v, loop_search_func search );
void loop_cleanup( loop* l );
int loop_is_empty( loop* l );
bool loop_remove( loop* l, qqpacket* data );
bool loop_remove_without_lock( loop* l, qqpacket* data,bool deleteit);

#endif
